package ru.pb.auth.utils;

import ru.pb.auth.configs.AuthServerConfig;
import ru.pb.global.crypt.Encode;
import ru.pb.global.crypt.SHA1;
import ru.pb.global.crypt.md5;

/**
 * Author: Felixx
 */
public class AccountUtils
{
	private static Encode _crypt;

	public static String encodePassword(String st)
	{
		if(_crypt == null)
		{
			if(AuthServerConfig.USE_MD5)
				_crypt = new md5();
			else
				_crypt = new SHA1();
		}

		return _crypt.encode(st);
	}

	public static boolean check(String normal, String hash)
	{
		return encodePassword(normal).equals(hash);
	}
}